<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>回访统计(全局)</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style>
        .layui-input {
            cursor: pointer;
        }

        .layui-tab-content {
            margin-left: 10px;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="layui-tab table_div">
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div>
                                    <div class="layui-form-item" style="margin-left: 20px">
                                        <div class="layui-input-inline">
                                            <label for="createTime"></label>
                                            <input type="text" readonly class="layui-input" id="createTime"
                                                   placeholder="创建时间">
                                        </div>
                                        <div class="layui-input-inline ">
                                            <button class="layui-btn" onclick="searchLog()" id="search">查询</button>
                                        </div>
                                    </div>
                                    <table class="layui-table" id="logShowTable" lay-filter="logShowTable"></table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab table_div1" hidden>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item">
                                    <div class="layui-btn layui-btn-primary" id="btn_cancel">返回</div>
                                </div>
                                <table class="layui-table" id="logShowTable1" lay-filter="logShowTable1"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">
    // 获取token
    let token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    let tokenQuery = token.replace("#", "%23");
    let logShowTable;
    let showTable;
    let table = layui.table;
    let form = layui.form;
    let layer = layui.layer;
    let $ = jQuery = layui.jquery;
    let laydate = layui.laydate;
    let upload = layui.upload;
    let element = layui.element;
    let maxlength = 500;
    let inspectionMan = "";
    let startTime = null;
    let endTime = null;
    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {
        //创建日期
        laydate.render({
            elem: '#createTime'
            , type: 'datetime'
            , range: '~'
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    startTime = value.split("~")[0];
                    endTime = value.split("~")[1];
                } else {
                    startTime = null;
                    endTime = null;
                }

            }
        });
        // 工作日志
        logShowTable = table.render({
            elem: '#logShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true,
            where: {
                "bz": 9
            },
            url: '/workflow/log/statisticslist',
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },

            cols: [[
                {
                    align: 'center',
                    width: 370,
                    field: 'taxorg',
                    title: '税务机关',
                    sort: true,
                }, {
                    align: 'center',
                    width: 170,
                    field: 'type1',
                    title: '日常日志',
                    sort: true,
                    event: 'type1',
                    style: 'cursor:pointer'
                }, {
                    align: 'center',
                    width: 170,
                    field: 'type2',
                    title: '案件日志',
                    sort: true,
                    event: 'type2',
                    style: 'cursor:pointer'
                }, {
                    align: 'center',
                    width: 220,
                    field: 'count',
                    title: '合计',
                    sort: true,
                    event: 'type',
                    style: 'cursor:pointer'
                }
            ]],
            toolbar: '#logToolbar'
        });
        // 工作日志
        logShowTable1 = table.render({
            elem: '#logShowTable1',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/log/querylist1' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },
            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'id',
                    title: '日志编号',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 180,
                    field: 'createId',
                    title: '填报人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 240,
                    field: 'taxPerson',
                    title: '确认人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 120,
                    field: 'type',
                    title: '日志类型',
                    sort: true,
                    templet: function (item) {
                        if (item.type === "1") {
                            return "日常日志";
                        } else if (item.type === "2") {
                            return "案件日志";
                        } else {
                            return "未知：" + item.type;
                        }
                    }
                }, {
                    align: 'center',
                    width: 340,
                    field: 'taxorgcode',
                    title: '税务机关',
                    sort: true,
                }, {
                    align: 'center',
                    width: 120,
                    field: 'contentdate',
                    title: '日志日期',
                    sort: true, templet: function (d) {
                        if (!d.contentdate) {
                            return '';
                        }
                        return layui.util.toDateString(d.contentdate, 'yyyy-MM-dd');
                    }
                }, {
                    align: 'center',
                    width: 218,
                    field: 'content1',
                    title: '完成工作',
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'sectionchiefContent',
                    title: '科长审批',
                    templet: function (item) {
                        if (item.sectionchiefContent === "") {
                            return "未审批内容";
                        } else {
                            return item.sectionchiefContent;
                        }
                    },
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'disciplineContent',
                    title: '纪检审批内容',
                    templet: function (item) {
                        if (item.disciplineContent === "") {
                            return "未审批";
                        } else {
                            return item.disciplineContent;
                        }
                    },
                    sort: true,
                }
            ]],
            toolbar: '#toolbar'
        });
        // 个人待办表头工具
        table.on('toolbar(logShowTable)', function (obj) {
            switch (obj.event) {
                case 'addinspectionhear':
                    addinspectionhear("0");
                    break;
                case 'add':
                    add();
                    break;
            }
        });
        //查询具体数据
        table.on('tool(logShowTable)', function (obj) {
            let event = obj.event;
            let taxorgcode = obj.data.taxorgcode;
            if (event === "type1") {
                // 处理你的业务逻辑
                searchLog1("1", taxorgcode)
            } else if (event === "type2") {
                searchLog1("2", taxorgcode)
            } else if (event === "type") {
                searchLog1("", taxorgcode)
            }
        })
        // 返回
        $("#btn_cancel").click(function () {
            $(".table_div").show();
            $(".table_div1").hide();
            return false;
        });
    });

    function search() {
        showTable.reload({
            where: {},
            page: {
                curr: 1
            }
        });
    }

    function searchLog() {
        logShowTable.reload({
            where: {
                startTime: startTime,
                endTime: endTime,
            },
            page: {
                curr: 1
            }
        });
    }

    function searchLog1(_typeId, taxorg) {
        $(".table_div").hide();
        $(".table_div1").show();
        logShowTable1.reload({
            where: {
                type: _typeId,
                taxorgcode: taxorg,
                startTime: startTime,
                endTime: endTime,
            },
            page: {
                curr: 1
            }
        });
    }

    function back() {
        search();
        searchLog();
    }

</script>

</body>
</html>